﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Media.PlayTo;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace SeachAndShareDemo
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            Loaded += MainPage_Loaded;
        }

        void MainPage_Loaded(object sender, RoutedEventArgs arg)
        {
            MySearchBox.SuggestionsRequested += ViewModel.SuggestionsRequested;
            MySearchBox.QuerySubmitted += (s, e) => this.Frame.Navigate(typeof(Views.SearchResults), e.QueryText);
            MySearchBox.ResultSuggestionChosen += (s, e) => new MessageDialog("Load " + e.Tag).ShowAsync();
        }

        ViewModels.MainPageViewModel ViewModel { get { return this.DataContext as ViewModels.MainPageViewModel; } }

        private void GridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            new MessageDialog("Load " + (e.ClickedItem as SeachAndShareDemo.Models.ColorItem).Name).ShowAsync();
        }
    }
}
